/* 
 * @(#)ForumststDaoImpl.java    Created on Apr 17, 2013
 * Copyright (c) 2013 ZDSoft Networks, Inc. All rights reserved.
 * $Id$
 */
package com.leruan.aasimp.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.leruan.aasimp.dao.ForumststDao;
import com.leruan.aasimp.entity.Forumstst;

public class ForumststDaoImpl extends HibernateDaoSupport implements ForumststDao {

    public void updateForumstst(Forumstst forumstst) {
        getHibernateTemplate().update(forumstst);
    }

    public Forumstst findForumststByUserId(String userId) {
        Session session = this.getSession();
        String hql = "from Forumstst where userId=?";
        return (Forumstst) session.createQuery(hql).setString(0, userId).uniqueResult();
    }

    public void insertForumstst(Forumstst forumstst) {
        // for (int i = 0; i < 1000; i++) {
        Session session = this.getSession();
        // Forumstst f = new Forumstst();
        // f.setUserId(StringUtil.getUUID());
        // f.setBrands(BrandList.getBrandList().get(i));
        // f.setCreatTime(new Date());
        // f.setModifyTime(new Date());
        session.save(forumstst);
        // System.out.println("done");
        // }
    }

    public void deleteForumstst(Forumstst forumstst) {
        Session session = this.getSession();
        String hql = "delete from Forumstst where userId=?";
        session.createQuery(hql).setString(0, forumstst.getUserId()).executeUpdate();
    }

    public List<Forumstst> findForumststs() {
        Session session = this.getSession();
        String hql = "from Forumstst";
        return session.createQuery(hql).list();
    }

}
